1bd990
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.redis.processor.idempotent;
 
+import java.time.Duration;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
@@ -52,11 +53,10 @@
public class RedisStringIdempotentRepository extends RedisIdempotentRepository {
     @ManagedOperation(description = "Adds the key to the store")
     @Override
     public boolean add(String key) {
-        boolean added = valueOperations.setIfAbsent(createRedisKey(key), key);
         if (expiry > 0) {
-            valueOperations.getOperations().expire(createRedisKey(key), expiry, TimeUnit.SECONDS);
+            return valueOperations.setIfAbsent(createRedisKey(key), key, Duration.ofSeconds(expiry));
         }
-        return added;
+        return valueOperations.setIfAbsent(createRedisKey(key), key);
     }
 
     @ManagedOperation(description = "Remove the key from the store")
